<template>
  <div class="stars" id="stars"></div>

  <div class="container">
    <div class="astronaut">
      <svg viewBox="0 0 512 512" xmlns="http://www.w3.org/2000/svg">
        <circle cx="256" cy="256" r="256" fill="#ffca28"/>
        <circle cx="256" cy="256" r="200" fill="#fff9c4"/>
        <circle cx="256" cy="256" r="150" fill="#ffeb3b"/>
        <circle cx="256" cy="256" r="100" fill="#ffca28"/>

        <!-- Astronaut -->
        <g class="astro" transform="translate(150, 150)">
          <!-- Helmet -->
          <circle cx="106" cy="106" r="60" fill="#e0e0e0"/>
          <circle cx="106" cy="106" r="45" fill="#f5f5f5"/>

          <!-- Visor -->
          <circle cx="106" cy="106" r="35" fill="#b3e5fc"/>
          <circle cx="120" cy="95" r="15" fill="#29b6f6"/>

          <!-- Body -->
          <ellipse cx="106" cy="190" rx="40" ry="50" fill="#e0e0e0"/>
          <rect x="66" y="190" width="80" height="60" fill="#e0e0e0"/>

          <!-- Arms -->
          <path d="M56 180 L16 220 L26 230 L66 190 Z" fill="#e0e0e0"/>
          <path d="M156 180 L196 220 L186 230 L146 190 Z" fill="#e0e0e0"/>

          <!-- Legs -->
          <path d="M76 250 L66 300 L86 300 L96 250 Z" fill="#e0e0e0"/>
          <path d="M116 250 L126 300 L146 300 L136 250 Z" fill="#e0e0e0"/>

          <!-- Oxygen tank -->
          <rect x="140" y="160" width="20" height="70" fill="#90a4ae" rx="10"/>
          <rect x="135" y="155" width="30" height="10" fill="#78909c" rx="5"/>
        </g>

        <!-- Floating elements -->
        <circle cx="100" cy="100" r="10" fill="#ff5252">
          <animate attributeName="cy" values="100;90;100" dur="2s" repeatCount="indefinite"/>
        </circle>
        <circle cx="400" cy="150" r="8" fill="#448aff">
          <animate attributeName="cy" values="150;140;150" dur="3s" repeatCount="indefinite"/>
        </circle>
        <circle cx="350" cy="350" r="12" fill="#69f0ae">
          <animate attributeName="cy" values="350;340;350" dur="4s" repeatCount="indefinite"/>
        </circle>
      </svg>
    </div>

    <h1>404</h1>
    <h2>哎呀，页面好像迷失在太空了</h2>
  </div>
</template>
<script setup>
import {onMounted} from 'vue'

document.title = '404'
onMounted(() => {
  function createStars() {
    const starsContainer = document.getElementById('stars')
    const starsCount = 150

    for (let i = 0; i < starsCount; i++) {
      const star = document.createElement('div')
      star.classList.add('star')

      const size = Math.random() * 3
      star.style.width = `${size}px`
      star.style.height = `${size}px`

      star.style.left = `${Math.random() * 100}%`
      star.style.top = `${Math.random() * 100}%`

      star.style.animationDuration = `${Math.random() * 3 + 2}s`
      star.style.animationDelay = `${Math.random() * 2}s`

      starsContainer.appendChild(star)
    }
  }

  // 添加鼠标移动视差效果
  document.addEventListener('mousemove', (e) => {
    const x = (window.innerWidth / 2 - e.clientX) / 25
    const y = (window.innerHeight / 2 - e.clientY) / 25

    document.querySelector('.astro').style.transform = `translate(${150 + x}px, ${150 + y}px)`
  })

  // 初始化
  window.addEventListener('load', () => {
    createStars()

    // 添加容器入场动画
    document.querySelector('.container').style.opacity = 1
    document.querySelector('.container').style.transform = 'translateY(0)'
  })
})
</script>
<style scoped>
.container {
  text-align: center;
}

@keyframes gradientBG {
  0% {
    background-position: 0% 50%;
  }
  50% {
    background-position: 100% 50%;
  }
  100% {
    background-position: 0% 50%;
  }
}

h1 {
  font-size: 6rem;
  margin-bottom: 1rem;
  text-shadow: 3px 3px 0 rgba(0, 0, 0, 0.2);
}

h2 {
  font-size: 2rem;
  margin-bottom: 2rem;
  font-weight: 300;
}

p {
  font-size: 1.2rem;
  margin-bottom: 2rem;
  line-height: 1.6;
  max-width: 600px;
  margin-left: auto;
  margin-right: auto;
}

.buttons {
  display: flex;
  justify-content: center;
  gap: 1rem;
  margin-top: 2rem;
}

.btn {
  padding: 1rem 2rem;
  border-radius: 50px;
  text-decoration: none;
  font-weight: 600;
  transition: all 0.3s ease;
  display: inline-block;
}

.btn-primary {
  background: #fff;
  color: #fdbb2d;
  box-shadow: 0 5px 15px rgba(0, 0, 0, 0.1);
}

.btn-primary:hover {
  transform: translateY(-3px);
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.2);
  background: #f8f8f8;
}

.btn-secondary {
  border: 2px solid #fff;
  color: #fff;
}

.btn-secondary:hover {
  background: rgba(255, 255, 255, 0.1);
  transform: translateY(-3px);
}

.astronaut {
  max-width: 300px;
  margin: 0 auto 2rem;
}

.stars {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: -1;
}

.star {
  position: absolute;
  background: #fff;
  border-radius: 50%;
  animation: twinkle linear infinite;
}

@keyframes twinkle {
  0%, 100% {
    opacity: 0.2;
  }
  50% {
    opacity: 1;
  }
}

@media (max-width: 768px) {
  h1 {
    font-size: 4rem;
  }

  h2 {
    font-size: 1.5rem;
  }

  p {
    font-size: 1rem;
  }

  .buttons {
    flex-direction: column;
  }
}
</style>
